<?php
class charticle_mdl extends CI_Model
{
	
	public function get_all()
	{
	$q = $this->db->get('charticle_v');
	return $q->result();		
	}
	
	public function get_id_article($nom_article)
	{
	$q = $this->db->query("SELECT articles.id_article
              FROM articles
             WHERE
articles.nom LIKE '$nom_article'
");
	return $q->result();
	}
	
	
	public function get_img()
	{
	$q = $this->db->query('SELECT facture.id_facture,facture.img_fact
FROM facture ');
	return $q->result();		
	}
	
	public function verifie_article($article)
	{
	$q = $this->db->query("SELECT articles.nom
FROM articles
WHERE articles.nom LIKE '$article'
");
	$cont=$q->num_rows();
return $cont;		
	}

    public function get_nom_article($id_article)
	{
	$q = $this->db->query("SELECT articles.nom
FROM articles
WHERE articles.id_article = $id_article

");
	return $q->result();
	}
	
	 public function get_chapitres()
	{
	$q = $this->db->query("SELECT
chapitres.nom
FROM
chapitres

");
	return $q->result();
	}
	
	 public function get_articles($ch)
	{
	$q = $this->db->query("SELECT
articles.nom AS nom_art,
articles.`code` AS code_art,
chapitres.nom AS nom_ch,
chapitres.`code` AS code_ch
FROM
articles
INNER JOIN chapitres ON articles.id_chapitre_fk = chapitres.id_chapitre
WHERE
articles.id_chapitre_fk = $ch
");
	return $q->result();
	}

     public function get_num_chapitre($num_ar)
	{
	$q = $this->db->query("SELECT
articles.id_chapitre_fk
FROM
articles
WHERE
articles.id_article = $num_ar
");
	return $q->result();
	}
}


?>